#pragma once
#include <map>
namespace Core
{
	namespace Pattern
	{
		template<class ConStateMachine,class _Message>
		class StateMachine
		{
		public:
			class State
			{
				typedef _Message Message;
				typedef ConStateMachine Machine;

				virtual State* HandleInput(Message& msg,Machine* machine)=0;
			};

			typedef  _Message Message;

			StateMachine(void){};
			void StateTransition(Message& msg)
			{
				current=current->HandleInput(msg,dynamic_cast<ConStateMachine>(this));
			}

		protected:
			const State* current;


		public:
			virtual ~StateMachine(void){};
		};
	}
}